implementation using NAND gate only